﻿using Godot;

namespace GoGameClient.script.common.button;

public partial class HighLightButton : TextureButton
{
    private ShaderMaterial _material;


    [Signal]
    public delegate void ButtonEventHandler(long id);


    public override void _Pressed()
    {
        EmitSignal(SignalName.Button, Id);
    }

    [Export] public long Id { get; set; }

    public override void _Ready()
    {
        // 加载Shader
        var shader = (Shader)GD.Load("res://resources/shader/HighLight.gdshader");
        // 创建ShaderMaterial
        _material = new ShaderMaterial();
        // 设置Shader
        _material.Shader = shader;
        MouseEntered += () => { Material = _material; };
        MouseExited += () => { Material = null; };
    }
}